#ifndef GOATVFS_H_
#define GOATVFS_H_

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#ifdef WIN32
#define GOATVFSAPI	__declspec(dllexport)
#else
#define GOATVFSAPI
#endif

typedef struct gvfs_file GVFS_FILE;
typedef struct gvfs_dir GVFS_DIR;

struct gvfs_dirent {
	char d_name[256];
};

struct gvfs_stat {
	unsigned int st_mode;
	unsigned long st_size;
};

extern int gvfs_errno;

#ifdef __cplusplus
extern "C" {
#endif

/* mount some target (which can be a directory or a pack filename) */
GOATVFSAPI int gvfs_mount(const char *mntpoint, const char *target);
GOATVFSAPI int gvfs_umount(const char *mntpoint);

GOATVFSAPI int gvfs_chdir(const char *path);
GOATVFSAPI int gvfs_mkdir(const char *path, unsigned int mode); /* XXX mode is ignored */

GOATVFSAPI GVFS_FILE *gvfs_fopen(const char *fname, const char *mode);
GOATVFSAPI int gvfs_fclose(GVFS_FILE *fp);

GOATVFSAPI int gvfs_fseek(GVFS_FILE *fp, long offset, int whence);
GOATVFSAPI long gvfs_ftell(GVFS_FILE *fp);
GOATVFSAPI void gvfs_rewind(GVFS_FILE *fp);

GOATVFSAPI size_t gvfs_fread(void *buf, size_t size, size_t nitems, GVFS_FILE *fp);
GOATVFSAPI size_t gvfs_fwrite(void *buf, size_t size, size_t nitems, GVFS_FILE *fp);

GOATVFSAPI int gvfs_fgetc(GVFS_FILE *fp);
GOATVFSAPI int gvfs_fputc(int c, GVFS_FILE *fp);

GOATVFSAPI char *gvfs_fgets(char *buf, int size, GVFS_FILE *fp);
GOATVFSAPI int gvfs_fputs(char *buf, GVFS_FILE *fp);

GOATVFSAPI int gvfs_fscanf(GVFS_FILE *fp, const char *fmt, ...);
GOATVFSAPI int gvfs_vfscanf(GVFS_FILE *fp, const char *fmt, va_list ap);
GOATVFSAPI int gvfs_fprintf(GVFS_FILE *fp, const char *fmt, ...);
GOATVFSAPI int gvfs_vfprintf(GVFS_FILE *fp, const char *fmt, va_list ap);

GOATVFSAPI void gvfs_clearerr(GVFS_FILE *fp);
GOATVFSAPI int gvfs_feof(GVFS_FILE *fp);
GOATVFSAPI int gvfs_ferror(GVFS_FILE *fp);

GOATVFSAPI GVFS_DIR *gvfs_opendir(const char *dirname);
GOATVFSAPI int gvfs_closedir(GVFS_DIR *dir);
GOATVFSAPI struct gvfs_dirent *gvfs_readdir(GVFS_DIR *dir);
GOATVFSAPI void gvfs_rewinddir(GVFS_DIR *dir);

GOATVFSAPI int gvfs_stat(const char *path, struct gvfs_stat *buf);

#ifdef __cplusplus
}
#endif

#endif	/* GOATVFS_H_ */
